/**
 * This is a panel class to display an image
 */
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import javax.swing.ImageIcon;
import javax.swing.JPanel;

/**
 * This is a panel class to display an image
 * @author Master
 * @version $Revision: 1.0 $
 */
public class ImagePanel extends JPanel {

	/**
	 * Field img.
	 */
	public Image img;

	/**
	 * Constructor for ImagePanel.
	 * @param img String
	 */
	public ImagePanel(String img) {
		this(new ImageIcon(img).getImage());
	}

	/**
	 * Constructor for ImagePanel.
	 * @param img Image
	 */
	public ImagePanel(Image img) {
		this.img = img;
		final Dimension size = new Dimension(img.getWidth(null), img.getHeight(null));
		setPreferredSize(size);
    	setMinimumSize(size);
    	setMaximumSize(size);
    	setSize(size);
    	setLayout(null);
	}
	
	/**
	 * Method paintComponent.
	 * @param g Graphics
	 */
	public void paintComponent(Graphics g) {
		g.drawImage(img, 0, 0, null);
	}

}